Repository navigation
Conversation
[Medium impact] The reviewed changes appear safe to merge.
|
G HUB depots name their renders by a path inside the depot (`images/device/<uuid>`). The fetch and the resolver joined every file name with `safe_component_path`, which accepts a single component only, so a G502 X PLUS colour variant never downloaded its front and side renders and could not have drawn them. Join depot files with the new `safe_relative_path`, which checks every `/`-separated segment with the same rules, and create the parent directory on write. The side view also looked its variant up by registry model id only, while the sync downloads by the manifest bases that include the depot name, which G HUB manifests key on. Resolve it through `find_variant_in_manifest` like the other variant renders. Fixes #2457
c34f7ac to
ee9d52c
Compare
|
Tested on hardware: white G502 X PLUS (
No ext2 unit here, so the WebP path is untested. |
|
Another depot this fixes: |
Summary
The
g502x_plusdepot names every render by its path inside the depot (images/device/<uuid>), and so do the other 44 G HUB depots in the asset catalog. Two defects kept a G502 X PLUS colour variant on the black base render with no side view:safe_component_path, which accepts only a single path component. Each sub-path file failed with "asset file name must be a single safe path component", so only the root files (front.png,manifest.json,metadata.json) were cached. The resolver also refused the same names, so they could not have been drawn even if they were cached.resolve_side_viewlooked up the variant'sdevice_sideusing only the registry model ids (c095,4099). The sync, anddrawable_variantsince fix(gui): draw the base model for a colour variant whose renders are not images #2379, usecandidate_manifest_bases, which adds the depot name. G HUB manifests key variants on the depot name (g502x_plus_ext1), so the lookup missed and fell back to aside.pngthat this depot does not ship. The same miss gave the drawable purple G502 LIGHTSPEED the blackside.pngnext to its purple front.Both mirrors serve the sub-path files: Pages and the jsDelivr shard
@logi-assets/pointing-gaming-xreturn the same bytes. So the fix is client-side only.Changes
openlogi-assetshttp::safe_relative_path. It splits a depot-relative path on/and runs every segment throughsafe_component_path, so empty,.,.., rooted, prefixed and backslash segments are still rejected and the joined path cannot leave the depot. Rejections report the newAssetError::UnsafeRelativePath.fetch_entry_if_stalejoinsfile.namewith it.write_replacecreates the destination's parent directory.ManifestResource::srcdocs now say thatsrccan be a sub-path.openlogi-desktopsafe_relative_path. Depot names still go throughsafe_component_path.resolve_side_viewnow resolves the variant's side render throughfind_variant_in_manifest(…, side_image_for). That is the lookup the sync downloads by, so the two can no longer disagree.This branch is rebased on #2463, which reads WebP render sizes (#2460). The G502 X PLUS ext2 renders are WebP under
images/device/, so they need both changes.Out of scope, filed separately: the macOS bundle (
openlogi assets sync) still selects optional files by flat name pattern, so it never includes sub-path renders (#2459).Testing
New regression tests. All of them fail on
masterand pass with this change:openlogi-assetshttp::tests::fetch_entry_writes_a_sub_path_file_into_its_depot_sub_directory: a local HTTP server; the fetch requests the sub-path, lands the file inimages/device/, and the second call is a cache hit.openlogi-desktopservices::assets::sync::tests::g502x_plus_sync_fetches_variant_renders_under_images_device:sync_depotfor the white variant (ext 1) fetches bothimages/device/renders.openlogi-desktopservices::assets::tests::a_colour_variant_draws_its_renders_from_a_depot_sub_directory: the white G502 X PLUS resolves its own front and side renders.openlogi-desktopservices::assets::tests::a_webp_colour_variant_draws_its_renders_from_a_depot_sub_directory: the ext2 G502 X PLUS resolves its WebP front and side renders fromimages/device/, each at its own size. This is the catalog layout end to end, on top of fix(gui): read webp render sizes for the side and main views #2463.a_drawable_colour_variant_keeps_its_renders_and_metadatagains a side-view assertion: the purple G502 LIGHTSPEED now gets its own side render.New guards:
safe_relative_path_accepts_names_and_depot_sub_paths,safe_relative_path_rejects_any_unsafe_segment, anda_manifest_sub_path_cannot_reach_outside_its_depot(images/../../side.pngis not read).Local gate, full tier after the rebase onto
b50c24e99(Linux; noCargo.tomlor lockfile change):Not run locally (left to CI): macOS and Windows clippy and tests, MSRV, and
cargo-deny.cargo-denyis not affected because no dependency changed.Not runtime-tested on hardware. To check: connect a white G502 X PLUS and start with an empty asset cache.
assets/g502x_plus/images/device/should then holde0e9dacc-…and22c9ac7a-…, and the Buttons tab should show the white render with the side view beside it. An ext2 unit should show its own WebP renders the same way.Fixes #2457